home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cc03.arc / INTC.C < prev    next >
Text File  |  1986-03-14  |  2KB  |  66 lines

  1. /* This is an illustration of the use of a generalized function to give      */
  2. /* access to IBM PC interupts from C (Lattice at least) using the subroutine */
  3. /* INTRPT contained in INTC.OBJ (source in INTC.ASM).  This subroutine will  */
  4. /* provide a standard interface to Lattice C (at least) to the interrupts    */
  5. /* provided.  All interrupts using register (not segment) elements are       */
  6. /* provided for, but the assembler program may be easily modified if segment */
  7. /* registers are required.  Communications done with the module are through  */
  8. /* external integers (again it is easy to change this).                      */
  9. /* Please note that the routine works under DOS 1.1 with version 1.04, and   */
  10. /* under DOS 2.0 with the new C.OBJ generated from the C.ASM module stored   */
  11. /* under this BBS.                                 */
  12. /*                                         */
  13. /*                B. K. Jenkins                     */
  14.  
  15.  
  16. #include    <stdio.h>
  17.  
  18. main()
  19. {
  20.  
  21. /* The following variables are the communication link to the INTRPT      */
  22. /* function in INTC.OBJ. r_ax is the value to be in the AX register      */
  23. /* when the interupt occurs, r_bx is the BX register, etc. and intrp     */
  24. /* is the interupt number.  Although these are declared as integer       */
  25. /* only the low order bytes are used as required (2 bytes for a register */
  26. /* 1 byte for intrp).  No validity checking for values occurs and are    */
  27. /* fully the responsibility of the programmer (i.e. you can mess around  */
  28. /* as well as mess up).                                                  */         
  29.     extern int intrpt();
  30.     extern int intrp,r_ax,r_bx,r_cx,r_dx;
  31.  
  32.     int dh,dl;
  33.  
  34. /* clear the screen (Type 10H, function 7H for whole screen) */
  35.     intrp = 0x10;
  36.     r_ax = 0x6 * 256 + 0;
  37.     r_bx = 0x7 * 256;
  38.     r_cx = 0;
  39.     r_dx = 25*256 +80;
  40.     intrpt();
  41.  
  42.     printf("The screen was cleared\n");
  43.  
  44. /* move cursor to top (Type 10H, function 2H) */
  45.     intrp = 0x10;
  46.     r_ax = 0x2 * 256 + 0;
  47.     r_bx = 0;
  48.     r_cx = 0;
  49.     r_dx = 0;
  50.     intrpt();
  51.  
  52. /* use the get date call (Type 21H, function 2AH) */
  53.     intrp = 0x21;
  54.     r_ax = 0x2a * 256 + 0;
  55.     r_bx = 256;
  56.     r_cx = 0;
  57.     r_dx = 0;
  58.     intrpt();
  59.  
  60.     dl = r_dx % 256; dh = r_dx / 256;
  61.  
  62.     printf("The date is %d/%d/%d (dd/mm/yy)\n",dl,dh,r_cx);
  63. }
  64.      printf("The date is %d/%d/%d (dd/mm/yy)\n",dl,dh,r_cx);
  65. }
  66.